<?php
/******************DB相关*********************/
define('DB_DEV_SERVER',	false);
defined('DB_DEBUG') || define('DB_DEBUG', false);
//	数据超过记录开始反转
defined('REVERSE_NUM')       || define('REVERSE_NUM', 5000);
define('DB_ERROR_LOG',	false);
//	define('DB_ERROR_LOG_FILE',     "/opt/wwwroot/qun_inner/cache/sql_error_log/db_error.log");
//	捕获执行时间大于n秒的sql,只可短暂开启
define('CAPTURE_LONGSQL_TIME',          0); //捕获大于该秒数的sql语句，(>0 && DB_DEBUG===false时为开启)
//	define('CAPTURE_LONGSQL_LOG_FILE',      "/opt/wwwroot/qun_inner/cache/sql_error_log/");

define('DB_RET_RES',        'RES');
define('DB_RET_ROW',        'ROW');
define('DB_RET_ROWS',       'ROWS');
define('DB_RET_VALUE',      'VALUE');
define('DB_RET_ROWS_PAGE',  'ROWS_PAGE');

define('DB_DEFAULT_PAGE_SIZE', 18);

/********************data source ************************************/
function &get_data_source($const_db, $param = null, $need_hash = true) 
{

    $hash        = ($param && $need_hash) ? md5($param) : null;
    $user        = null;
    $pass        = null;
    $port        = null;
    $table       = null;
    $table_alias = null;

 /********************************************************************/
    switch ($const_db)
    {
		
		case 'xydzp2_userinfo':	//用户资料
		case 'xydzp2_partner': //参与者
		case 'xydzp2_lottery_log': //抽奖记录
		case 'xydzp2_prize'://奖品设置
		case 'xydzp2_goods_log'://实物

            $host = '10.21.2.190';
			$user = 'dmz';
			$pass = 'dmz8PHtvbRZoEZdS';	
            	
            $database = 'dmz_act_basic';			
            $table = $const_db;           
			break;
		/*电信一区*/
		case 'lucky_turntable_pay_1':	//充值送免费抽奖机会
		case 'lucky_dial_login_1':	//每日登陆送免费抽奖机会
			$host = '10.21.2.185';
			$user = 'dmz';
            $pass = 'dmz8PHtvbRZoEZdS';
            $database = 'dmz_activity';			
            $table = $const_db;           
			break;
		/*电信二区*/
		case 'lucky_turntable_pay_2':	//充值送免费抽奖机会
		case 'lucky_dial_login_2':	//每日登陆送免费抽奖机会
			$host = '10.10.4.57';
			$user = 'dmz';
            $pass = 'dmz8PHtvbRZoEZdS';
            $database = 'dmz_activity';			
            $table = $const_db;           
			break;
		/*网通一区*/
		case 'lucky_turntable_pay_101':	//充值送免费抽奖机会
		case 'lucky_dial_login_101':	//每日登陆送免费抽奖机会
			$host = '10.21.2.11';
			$user = 'dmz';
            $pass = 'dmz8PHtvbRZoEZdS';
            $database = 'dmz_activity';			
            $table = $const_db;           
			break;
        default :
            $ret = array();
            return $ret;
    }

 /********************************************************************/

    $ret = array(   'host'          => $host.($port ? ":{$port}" : ''),
                    'user'          => is_null($user) ? "xxxx" : $user,
                    'pass'          => is_null($pass) ? "xxxx" : $pass,
                    'database'      => $database,
                    'table'         => $table,
                    'table_alias'   => $table_alias
                );
	//var_dump($ret);
    return $ret;
}
### end data source ###########################################################
?>
